<?php


namespace Modules\Admin\Http\Controllers\Authorization\Permission;


use Illuminate\Support\Facades\DB;
use Modules\Common\General\Security\Authorization\Manager;
use Modules\Common\Models\AdminPermission;
use Modules\Common\Models\AdminUser;
use Modules\Common\Models\EmployeeUser;
use Modules\Common\Models\Project;
use Modules\Common\Util\Api;
use Modules\Common\Util\Database;

class Delete
{
    /**
     * @Route(path=/api/admin/authorization/permission method=delete)
     */
    public function index()
    {
        Api::validate(['permission_id' => 'integer', 'branch_id' => 'integer']);
        DB::transaction(function () {
            $permission = AdminPermission::find(request('permission_id'));
            $permission->forceDelete();
            $m = new Manager();
            $m->deletePermission(request('permission_id'), request('branch_id'));
        });
        return Api::success();
    }

}